Release 10.1A: OpenEdge Data Management:
DataServer for ORACLE
Query tuning
In addition to the standard approach of using selection criteria to refine access to data, you can further influence how the DataServer executes a query through the Progress
QUERY-TUNINGphrase. How you structure a query determines how efficiently you access a database. Efficient use of the ORACLE RDBMS enhances the performance of DataServer applications. You can include theQUERY-TUNINGphrase for the following Progress 4GL statements:Place the
QUERY-TUNINGphrase after the last record phrase. For example, place it near the end of the statement where you also place block modifier phrases such asBREAK,ONERROR, andTRANSACTION. Separate multiple query-tuning options by a single space. TheQUERY-TUNINGoptions have equivalent startup parameters. You cannot use the startup parameters to override theQUERY-TUNINGsettings.Table 4–1 describes the query-tuning options.
Table 4–1: Query-tuning options Option DescriptionARRAY-MESSAGENO-ARRAY-MESSAGE Specifies whether the DataServer sends multiple result rows in a single logical network message, thereby reducing network traffic.
Default:ARRAY-MESSAGE, if the query uses a lookahead cursor.BIND-WHERENO-BIND-WHERE Specifies whether the DataServer uses ORACLE bind variables for values inWHEREclauses. Using bind variables typically improves performance, but ORACLE provides unexpected results for some operations, such as aMATCHESon an indexed field and a trailing wild card or comparisons ofCHARfields that use ORACLE’s blank-padding rules.
SpecifyNO-BIND-WHEREto use literals. UsingNO-BIND-WHEREin queries that do comparisons (MATCHES,BEGINSon an indexed field) can improve performance.
Default:BIND-WHERE.CACHE-SIZEintegerBYTECACHE-SIZEintegerROW Specifies the size of the cache for information (in bytes or records) used by lookahead or standard cursors. If you have two Progress 4GL statements that cause the DataServer to generate identical SQL code except that the second statement specifies a smaller cache size, the DataServer reuses the larger cache from the first statement if the cursor is still available. Reusing cache and cursors improves performance.
Byte maximum: 65535 bytes.
Byte minimum: Specify the number of bytes contained in a single record. For joins, specify the number of bytes contained in two joined records. By default, the DataServer sizes the cache to accommodate one record or, for a join, two joined records. For example, if a join returns a 500-byte record, you need a cache of at least 1000 bytes.
Default: 1024 bytes with standard cursors; 8192 with lookahead cursors.
Row maximum: the number of records that can fit in 65535 bytes. See the "Caching records" section for more information.
Row minimum: 1 for a single table; 2 for a join.DEBUG EXTENDEDDEBUG SQLNO-DEBUG Specifies whether the DataServer should print debugging information that it generates for the query to thedataserv.lgfile.
SpecifyDEBUGSQLto print the SQL that the DataServer executes against the ORACLE DBMS.
SpecifyDEBUGEXTENDEDto print additional information, such as cursor statistics.
There are additional options for collecting advanced statistics withDEBUG. See the "Analyzing performance" section for more information.
Default:NO-DEBUG.HINTstring1 string2 string3 Specifies the ORACLE hint syntax that the DataServer passes directly to the ORACLE DBMS as part of the query. This allows you to control which hints are passed as opposed to the index hints that the DataServer passes when appropriate.
When you have to specify an index name in the hint syntax, use the name defined in the ORACLE database. Because the DataServer generates aliases for ORACLE tables using names from T0 through T9, use these aliases to refer to tables in the hint syntax.
The DataServer passes the opening symbols (/*+) and closing symbols (*/). For example, to pass the/*+ORDERED*/hint syntax, you specify onlyHINT"ORDERED".
Passing incorrect hint syntax, inappropriate hints, or conflicting hints will not return an error but might give you unpredictable results. See your ORACLE documentation for information on hint syntax.INDEX-HINTNO-INDEX-HINT Specifies whether the DataServer should provide index hints to the ORACLE DBMS. Generally, index hints improve performance, but ORACLE’s responses to hints vary between releases.
SpecifyNO-INDEX-HINTto test whether performance for a query improves when the DataServer executes it without hints. See the "Indexes" section for more information on index hints.
By default, the DataServer passes index hints. You can turn off the default globally at compile time or run time by specifying the-noindexhintstartup parameter when you start an OpenEdge session. UseINDEX-HINTto retain the behavior for individual queries.
Default:INDEX-HINT.JOIN-BY-SQLDBNO-JOIN-BY-SQLDB Specifies whether the DataServer allows the ORACLE DBMS to perform a join, which usually improves performance.
Default:JOIN-BY-SQLDB.
You can turn off theJOIN-BY-SQLDBdefault globally at compile time by specifying the-nojoinbysqldbstartup parameter when you start an OpenEdge session. The-nojoinbysqldbparameter does not override the explicit use ofJOIN-BY-SQLDBin theQUERY-TUNINGphrase.LOOKAHEADNO-LOOKAHEAD Specifies whether the DataServer uses lookahead or standard cursors. Lookahead cursors fetch as many records as fit in the allocated cache (CACHE-SIZE), which limits the number of database accesses, thereby improving performance.
Using lookahead cursors results in behavior that is different from the Progress 4GL because the client does not see any changes made to the records in the cache. SpecifyNO-LOOKAHEADfor behavior that is consistent with the Progress 4GL.
Default:LOOKAHEAD, except withFINDstatements and statements that use anEXCLUSIVElock.ORDERED-JOIN Specifies that the DataServer embed theORDEREDhint syntax in the SQL it generates.REVERSE-FROM Specifies that ORACLE join tables in the reverse order in which they appear in theFROMclause. The DataServer generates a new SQLFROMclause with the tables in reverse order.
REVERSE-FROMis independent of theORDERED-JOINoption.Note: All of the query-tuning options take effect at both compile and run time except for the
INDEX-HINT,JOIN-BY-SQLDB, andNO-JOIN-BY-SQLDBoptions, which apply only at compile time.The following example shows how to use the
QUERY-TUNINGphrase to enhance performance. It includes a join which the DataServer instructs ORACLE to perform by default. TheQUERY-TUNINGoptions specify that no lookahead cursors will be used. In addition, the DataServer will write an extended report on the SQL statements it executes, as shown:
This example shows how to use the
QUERY-TUNINGphrase to manage cache size so that the DataServer can reuse cursors and cache, thereby improving performance. The phrase also passes a hint to the ORACLE optimizer to choose the cost-based approach to optimize the statement for best response time. Finally, theDEBUGEXTENDEDoption causes the DataServer to report on the SQL statements it executes, as shown:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |